//
//  ConversationCell.m
//  Coding_iOS
//
//  Created by 王 原闯 on 14-8-29.
//  Copyright (c) 2014年 Coding. All rights reserved.
//

#import "ConversationCell.h"
#import "UIColor+expanded.h"
#import "UIImageView+WebCache.h"
#import "NSObject+Common.h"

@interface ConversationCell ()
@property (strong, nonatomic) UIImageView *userIconView;
@property (strong, nonatomic) UILabel *name, *msg, *time;

@end

@implementation ConversationCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        if (!_userIconView) {
            _userIconView = [[UIImageView alloc] initWithFrame:CGRectMake(5,5, 40, 40)];
           // [_userIconView doCircleFrame];
            [self.contentView addSubview:_userIconView];
        }
        if (!_name) {
            _name = [[UILabel alloc] initWithFrame:CGRectMake(75, 8, 150, 25)];
            _name.font = [UIFont systemFontOfSize:17];
            _name.textColor = [UIColor redColor];
            _name.backgroundColor = [UIColor clearColor];
            [self.contentView addSubview:_name];
        }
        if (!_time) {
            _time = [[UILabel alloc] initWithFrame:CGRectMake(300 - 100-5, 8, 100, 25)];
            _time.font = [UIFont systemFontOfSize:12];
            _time.textColor = [UIColor blueColor];
            _time.textAlignment = NSTextAlignmentRight;
            _time.backgroundColor = [UIColor clearColor];
            [self.contentView addSubview:_time];
        }
        if (!_msg) {
            _msg = [[UILabel alloc] initWithFrame:CGRectMake(75, 30, 300-75-30 -5, 25)];
            _msg.font = [UIFont systemFontOfSize:15];
            _msg.backgroundColor = [UIColor clearColor];
            _msg.textColor = [UIColor redColor];;
            [self.contentView addSubview:_msg];
        }
    }
    return self;
}

- (void)layoutSubviews{
    [super layoutSubviews];
      NSString *str = @"http://mbpcos.image.alimmdn.com/avatar/D6B77C75-42B1-4AB6-9A99-2FD06381CC11@50w";
    if (_bean) {
        str = _bean.avatarUrl;
    }
    str = [str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
     NSURL *url = [NSURL URLWithString:str];
    //[_userIconView sd_setImageWithURL:url];
   [_userIconView sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"a"]];

    _name.text = @"kokuma";
    if(_bean&&_bean.displayName){
       _name.text = _bean.displayName;
    }
    _time.text = @"2017.02.06";
    if(_bean){
        _time.text = @"关注";
    }
    _msg.textColor = [UIColor brownColor];
    _msg.text = @"小样儿粗不粗来";
    if(_bean&&_bean.extInfos){
        _msg.text = _bean.extInfos;
    }
    UITapGestureRecognizer *tapG = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tappedFollow)];
}

-(void)tappedFollow{
    [NSObject showHudTipStr:[NSString stringWithFormat:@"%@,%@", @"您关注了", _bean.displayName ]];
}

+ (CGFloat)cellHeight{
    return 61;
}

@end
